package br.utfpr.edu.managedBean;

import java.io.InputStream;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.ServletContext;

import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;


@ManagedBean(name = "downloadFrm")
@RequestScoped
public class DownloadFrm {
	
	private StreamedContent file;  
    
    public void FileDownloadController(ActionEvent event) {          
        InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/documentation/doc.pdf");  
        file = new DefaultStreamedContent(stream, "application/pdf'", "doc.pdf");
    }  
  
    public StreamedContent getFile() {  
        return file;  
    }    

}
